<!-- 报告编审及审核 -->
<template>
  <div>
    <Card :bordered="false">
      <p slot="title">报告编制情况表</p>
      <p>
        <Form ref="form" :model="info" :rules="rules">
          <table id="reportReview" width='100%' border="1" cellspacing="0" cellpadding="0" ref="print">
            <tr>
              <th colspan="6">
                报告编制情况表
              </th>
            </tr>
            <tr>
              <td width="270">
                项目编号
              </td>
              <td colspan="5">
                {{info.Project_number}}
              </td>
            </tr>
            <tr>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                项目名称
              </td>
              <td colspan="5">
                <FormItem prop="Project_name">
                  <Input v-model="info.Project_name"></Input>
                </FormItem>
              </td>
            </tr>
            <tr>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                建设单位
              </td>
              <td colspan="5">
                <FormItem prop="Build_unit">
                  <Input v-model="info.Build_unit"></Input>
                </FormItem>
              </td>
            </tr>
            <tr>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                报告类型
              </td>
              <td colspan="3">
                <FormItem prop="Peport_type">
                  <Input v-model="info.Peport_type"></Input>
                </FormItem>
              </td>
              <td width="300">
                <Icon type="ios-medical" color="#ff6868" />
                联系人
              </td>
              <td>
                <FormItem prop="Linkman">
                  <Input v-model="info.Linkman"></Input>
                </FormItem>
              </td>
            </tr>
            <tr>
              <td>
                项目负责人
              </td>
              <td colspan="3">
                <Input v-model="info.Perject_leader"></Input>
              </td>
              <td>
                项目组成员
              </td>
              <td>
                <Input v-model="info.Linkman"></Input>
              </td>
            </tr>
            <tr>
              <td rowspan="14">
                初稿
              </td>
              <td rowspan="14">
                报告
              </td>
              <td colspan="2">
                正文
              </td>
              <td>
                <Button type="default">新建报告</Button>
              </td>
              <td>
                <UploadFile v-model="info.Project_trust_instrument" />
              </td>
            </tr>
            <tr>
              <td rowspan="6">
                附件
              </td>
              <td>
                <Checkbox label="twitter">
                </Checkbox>
              </td>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                委托书
              </td>
              <td>
                <Row>
                  <Col span="16">
                  <Alert type="success" show-icon>土地文件.doc</Alert>
                  </Col>
                  <Col span="8">
                  <FormItem prop="Project_trust_instrument">
                    <UploadFile v-model="info.Project_trust_instrument" />
                  </FormItem>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td>
                <Checkbox label="twitter">
                </Checkbox>
              </td>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                备案/立项文件
              </td>
              <td>
                <Row>
                  <Col span="16">
                  <Alert type="success" show-icon>土地文件.doc</Alert>
                  </Col>
                  <Col span="8">
                  <FormItem prop="Create_project_doc">
                    <UploadFile v-model="info.Create_project_doc" />
                  </FormItem>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td>
                <Checkbox label="twitter">
                </Checkbox>
              </td>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                土地文件
              </td>
              <td>
                <Row>
                  <Col span="16">
                  <Alert type="success" show-icon>土地文件.doc</Alert>
                  </Col>
                  <Col span="8">
                  <FormItem prop="Land_doc">
                    <UploadFile v-model="info.Land_doc" />
                  </FormItem>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td>
                <Checkbox label="twitter">
                </Checkbox>
              </td>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                规划文件
              </td>
              <td>
                <Row>
                  <Col span="16">
                  <Alert type="success" show-icon>土地文件.doc</Alert>
                  </Col>
                  <Col span="8">
                  <FormItem prop="Planning_doc">
                    <UploadFile v-model="info.Planning_doc" />
                  </FormItem>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td>
                <Checkbox label="twitter">
                </Checkbox>
              </td>
              <td>
                执行标准函
              </td>
              <td>
                <Row>
                  <Col span="16">
                  <Alert type="success" show-icon>土地文件.doc</Alert>
                  </Col>
                  <Col span="8">
                  <Upload action="//jsonplaceholder.typicode.com/posts/">
                    <Button>上传</Button>
                  </Upload>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td colspan="3">
                <Row>
                  <Col span="24">
                  <Button style="margin-right: 20px" type="info">添加</Button><Button type="error">删除</Button>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td rowspan="6">
                附图
              </td>
              <td>
                <Checkbox label="twitter">
                </Checkbox>
              </td>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                地理位置图
              </td>
              <td>
                <Row>
                  <Col span="16">
                  <FormItem prop="Planning_doc">
                    <UploadFile v-model="info.Planning_doc" />
                  </FormItem>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td>
                <Checkbox label="twitter">
                </Checkbox>
              </td>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                周围环境概况图
              </td>
              <td>
                <Row>
                  <Col span="16">
                  <Upload action="//jsonplaceholder.typicode.com/posts/">
                    <Button>上传</Button>
                  </Upload>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td>
                <Checkbox label="twitter">
                </Checkbox>
              </td>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                项目平面分布图
              </td>
              <td>
                <Row>
                  <Col span="16">
                  <Upload action="//jsonplaceholder.typicode.com/posts/">
                    <Button>上传</Button>
                  </Upload>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td>
                <Checkbox label="twitter">
                </Checkbox>
              </td>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                项目监测布点图
              </td>
              <td>
                <Row>
                  <Col span="16">
                  <Upload action="//jsonplaceholder.typicode.com/posts/">
                    <Button>上传</Button>
                  </Upload>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td>
                <Checkbox label="twitter">
                </Checkbox>
              </td>
              <td>
                <Icon type="ios-medical" color="#ff6868" />
                项目水系图
              </td>
              <td>
                <Row>
                  <Col span="16">
                  <Upload action="//jsonplaceholder.typicode.com/posts/">
                    <Button>上传</Button>
                  </Upload>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td colspan="3">
                <Row>
                  <Col span="24">
                  <Button type="info" style="margin-right: 20px">添加</Button><Button type="error">删除</Button>
                  </Col>
                </Row>
              </td>
            </tr>
            <tr>
              <td>
                附表
              </td>
              <td colspan="3" style="text-align:left">
                <Button type="info" ghost>基础信息表</Button>
              </td>
            </tr>
          </table>
        </Form>
        <Row style="padding:20px 0">
          <Col span="12" style="text">
          <PrintButton v-if="flag" Url="print/printFormation" :Project_id="info.Id"></PrintButton>
          </Col>
          <Col span="12" style="text-align: right">
          <Button type="primary" @click="submit('save')">
            保存
          </Button>
          <Button type="primary" @click="submit('submit')">
            提交审核
          </Button>
          </Col>
        </Row>
      </p>
      <StepBar :status="4" />
    </Card>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        flag: false,
        info: {},
        rules: {
          Project_name: {
            required: true,
            trigger: 'blur',
            message: '内容不能为空',
          },
          Build_unit: {
            required: true,
            trigger: 'blur',
            message: '内容不能为空',
          },
          Peport_type: {
            required: true,
            trigger: 'blur',
            message: '内容不能为空',
          },
          Linkman: {
            required: true,
            trigger: 'blur',
            message: '内容不能为空',
          },
          Project_trust_instrument: {

          },
          Create_project_doc: {

          },
          Land_doc: {

          },
          Planning_doc: {

          },
        }
      }
    },
    created() {
      //判断是否有ID
      if (this.$route.query.Project_id && this.$route.query.Project_id != '') {
        this.getProject(this.$route.query.Project_id)
      } else {
        //跳转首页
        this.$router.push({
          name: "index"
        })
      }
    },
    methods: {
      ok() {
        this.$Message.info("Clicked ok");
      },
      cancel() {
        this.$Message.info("Clicked cancel");
      },

      addData() {
        this.data1.push({
          name: "项目负责人",
          address: "负责的章节"
        })
      },
      /* 获取当前创建项目 */
      getProject(id) {
        axios.get('/projectInformation/findProjectByID', {
          params: {
            id
          }
        }).then(res => {
          this.info = res.info
          localStorage.projectType = this.info.Perject_type
          this.flag = true
        })
      },
      // 保存 save / 提交 submit
      submit(type) {
        // 验证
        this.$refs.form.validate((valid) => {
          if (!valid) {
            return
          }

          let info = this.info

          info.btn_way = type == 'save' ? 1 : 2
          info.Perject_type = type == 'save' ? 5 : 5

          console.log(this.info)
          axios.post('/projectInformation/saveOrUpdateProject', info).then((res) => {
            if (res._STATUS == 1) {
              let title = res._MESSAGE
              if (type == 'save') {
                this.$Modal.success({
                  title,
                })
              } else {
                // 如果是总公司为跳入三审 分公司跳入五审核
                if (info.Project_level == 0) {
                  this.$router.push({
                    name: "firstTrial",
                    query: {
                      Project_id: this.$route.query.Project_id,
                      Atype: 2,
                    }
                  })
                } else {
                  this.$router.push({
                    name: "firstInstance",
                    query: {
                      Project_id: this.$route.query.Project_id,
                      Atype: 0,
                    }
                  })
                }

              }
            } else {
              // 提示
              this.$Modal.error({
                title,
              })
            }
          })
        })
      },
    }
  }
</script>
<style lang="less">
  #reportReview {
    .ivu-input {
      border: none !important;
      text-align: center;
      height: 30px;

      input {
        outline: medium;
      }
    }
  }
</style>